#!/bin/bash
#
#HPCI -n wrapt
#HPCI -v 1.10.10
#HPCI -a wrapt-1.10.10.tar.gz
#HPCI -p gnu/4.8.2
#HPCI -p python/2.7.7 

set -e

PKGSRC=$HPCI_SW_NAME"-"${HPCI_SW_VERSION}

tar -xf $PKGSRC".tar.gz"
cd $PKGSRC
python setup.py build

# Create the module directory
mkdir -p $HPCI_MOD_DIR/pythonpkgs/$HPCI_SW_NAME/

# Create the module with the following template
cat << EOF > $HPCI_MOD_DIR/pythonpkgs/$HPCI_SW_NAME/${HPCI_SW_VERSION}.lua
require("posix")

whatis("wrapt v$HPCI_SW_VERSION")

help([[
This module loads wrapt, a Python package that provides fully functional 
decorators.  See https://wrapt.readthedocs.io/en/latest/ for details.
]])

local verpath = "$HPCI_SW_DIR" -- specific version path
local pytestpath = pathJoin(verpath, "lib/python2.7/site-packages/") -- internal python libs

prepend_path("PYTHONPATH", pytestpath)

conflict("all-python-libs")
EOF

mkdir -p $HPCI_SW_DIR/lib/python2.7/site-packages/  # create the install directory (python does not install in not existing dirs)

# Need to set pythonpath in order to dump the .pth files
ml use $HPCI_MOD_DIR/pythonpkgs
ml $HPCI_SW_NAME/${HPCI_SW_VERSION}

python setup.py install --prefix=$HPCI_SW_DIR
